package view;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.FileInputStream;

import javax.swing.JPanel;

/**
 * Het welkomscherm toont de welkomscherm.jpg afbeelding.
 * @author Marvin
 * @author Yoeri
 * @since 31-05-2010
 *
 */

@SuppressWarnings("serial")
public class WelkomSchermView extends JPanel {
	
	private int BEGINWIDTH = 600;
	private int BEGINHEIGHT = 600;
	private Image image;
	
	public WelkomSchermView() {
		image = getFileImage("./files/welkomscherm.jpg");
		
	}
	
	public void paintComponent(Graphics g) {
        super.paintComponent(g);

        Graphics2D g2   = (Graphics2D) g;
        Double mbreedte = new Double(getWidth()) / BEGINWIDTH;
        Double mhoogte  = new Double(getHeight()) / BEGINHEIGHT;

        g2.scale(mbreedte, mhoogte);
        if (image != null) {
        	g.drawImage(image, 0, 0, this);
        }
	}
	
	private Image getFileImage(String filePath) {
	    try {
	        FileInputStream in = new FileInputStream(filePath);
	        byte[] b           = new byte[in.available()];

	        in.read(b);
	        in.close();

	        return Toolkit.getDefaultToolkit().createImage(b);
	    } catch (Exception ex) {}
	    return null;
	}
	
	

	
}
